#define _CRT_SECURE_NO_WARNINGS 1
#include <climits>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> a(n, 0);
    for (int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int MinD = INT_MAX;
    for (int i = 1;i < a.size();i++)
    {
        if (a[i] - a[i - 1] < MinD)
        {
            MinD = a[i] - a[i - 1];
        }
        if (MinD == 0) break;
    }
    cout << MinD << endl;
    return 0;
}
